﻿//UserInfo.aspx.cs
////////////////////////////////////////
////////////////////////////////////////
//当点击主页左侧登录控件里的个人信息按钮时显示，显示用户的所有信息，用户可以修改个人信息并保存
////////////////////////////////////////
////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data;

public partial class Userinfo : System.Web.UI.Page
{
    CommonClass ccObj = new CommonClass();
    protected void Page_Load(object sender, EventArgs e)
    {
        //通过Session["User"]在主页里显示用户所有的信息。
        Client user = (Client)Session["User"];
        txtName.Text = user.userName;
        txtTrueName.Text = user.realName;
        txtPhone.Text = user.phone;
        txtEmail.Text = user.email;
        txtAddress.Text = user.address;        
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Client user = (Client)Session["User"];
        if (user.UpdateUserInfo(user.clientID, txtName.Text.ToString().Trim(),
                                txtTrueName.Text.ToString().Trim(),
                                txtAddress.Text.ToString().Trim(),
                                txtPhone.Text.ToString().Trim(),
                                txtEmail.Text.ToString().Trim()))
        {
            Response.Write(ccObj.MessageBox("修改成功！", "Default.aspx"));
        }
        else
        {
            Response.Write(ccObj.MessageBox("修改失败！"));
        }
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        Response.Redirect("Default.aspx");
    }
}
